﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Nasa8x.Mvc
{
   public static class Extensions
    {
       public static SelectList ToSelectList<T>(this IEnumerable<T> items, string dataValueField, string dataTextField, string selectedValue)
       {
           return new SelectList(items, dataValueField, dataTextField, selectedValue);
       }


       public static IEnumerable<SelectListItem> GetEnumSelectList<T>()
       {
           return (Enum.GetValues(typeof(T)).Cast<T>().Select(
               enu => new SelectListItem() { Text = enu.ToString(), Value = enu.ToString() })).ToList();
       }

       

    }
}
